package message.handler;

import java.util.Collection;

import net.VirtualQueue;

public class OfflineHandler implements Runnable{
	
	String loggingOutUser;
	
	public OfflineHandler(String loggingOutUser) {
		this.loggingOutUser = loggingOutUser;
	}

	@Override
	public void run() {
		VirtualQueue vq = VirtualQueue.obtainVirtualQueue();
		Collection<String> poppedMessages = vq.removeOutgoingMessagesTo(loggingOutUser);
		for (String m : poppedMessages)
			new Thread(new PersistentMessageHandler(m, loggingOutUser)).start();
	}
}
